package com.wedo.mall.entity;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

/**
 * 商品属性
 * Created by e on 2017/7/9.
 * @see AttrItem
 */
public class Attr implements Parcelable {

    public String id;
    public String attr_name;
    public List<AttrItem> attrValue;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Attr)) return false;

        Attr attr = (Attr) o;

        return id.equals(attr.id);
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.attr_name);
        dest.writeList(this.attrValue);
    }

    public Attr() {
    }

    protected Attr(Parcel in) {
        this.id = in.readString();
        this.attr_name = in.readString();
        this.attrValue = new ArrayList<AttrItem>();
        in.readList(this.attrValue, AttrItem.class.getClassLoader());
    }

    public static final Parcelable.Creator<Attr> CREATOR = new Parcelable.Creator<Attr>() {
        @Override
        public Attr createFromParcel(Parcel source) {
            return new Attr(source);
        }

        @Override
        public Attr[] newArray(int size) {
            return new Attr[size];
        }
    };
}
